package com.mooc.lib_find.ui.find_ist

import com.mooc.lib_find.ApiService
import com.mooc.lib_find.model.FindListEntity
import com.mooc.lib_find.model.FollowEntity
import com.mooc.lib_network.entity.BaseRepository
import com.mooc.lib_network.entity.NetResult
import com.mooc.lib_network.entity.RetrofitSingle

class FindRepo : BaseRepository() {

    suspend fun find(userId : Int,tagType : String,
                     tagId: Int,pageCount : Int,offset : Int):NetResult<FindListEntity>{
        return requestCall(call = {requestFind(userId,tagType,tagId,pageCount,offset)})
    }

    suspend fun requestFind(userId : Int,tagType : String,
                            tagId: Int,pageCount : Int,offset : Int):NetResult<FindListEntity>{
        return handlerResponse(
            RetrofitSingle.instance().getRetrofit().create(ApiService::class.java)
                .requestFindList(offset,pageCount,tagType,tagId,userId)
        )
    }

    suspend fun follow(userId : Int,tagId: Int):NetResult<FollowEntity>{
        return requestCall ( call = {requestFollow(userId,tagId)})
    }

    //关注挂起函数
    suspend fun requestFollow(userId : Int,tagId: Int):NetResult<FollowEntity>{
        return handlerResponse(
            RetrofitSingle.instance().getRetrofit().create(ApiService::class.java)
                .requestFindFollow(tagId,userId)
        )
    }


}